
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>qilu-mybatis · 启路框架-使用手册</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-lightbox/css/lightbox.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-flexible-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-page-toc-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="logTrace-readme.html" />
    
    
    <link rel="prev" href="cache-readme.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    整体介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../ready/ready.html">
            
                <a href="../ready/ready.html">
            
                    
                    技术准备
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../ready/ide.html">
            
                <a href="../ready/ide.html">
            
                    
                    eclipse
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../ready/build.html">
            
                <a href="../ready/build.html">
            
                    
                    本地构建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../ready/nexus.html">
            
                <a href="../ready/nexus.html">
            
                    
                    私服构建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../ready/run.html">
            
                <a href="../ready/run.html">
            
                    
                    运行调试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../ready/specification.html">
            
                <a href="../ready/specification.html">
            
                    
                    结构和分包
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="baseReadme.html">
            
                <a href="baseReadme.html">
            
                    
                    基础包介绍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="qiluTask-readme.html">
            
                <a href="qiluTask-readme.html">
            
                    
                    qilu-task
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="cache-readme.html">
            
                <a href="cache-readme.html">
            
                    
                    qilucache
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.3" data-path="qiluMybatis-readme.html">
            
                <a href="qiluMybatis-readme.html">
            
                    
                    qilu-mybatis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="logTrace-readme.html">
            
                <a href="logTrace-readme.html">
            
                    
                    qilu-logTrace
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="qilu-export-readme.html">
            
                <a href="qilu-export-readme.html">
            
                    
                    qilu-export
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="httpService-readme.html">
            
                <a href="httpService-readme.html">
            
                    
                    qilu-http-service
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="validateReadme.html">
            
                <a href="validateReadme.html">
            
                    
                    qilu-validate
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../state/state-course.html">
            
                <a href="../state/state-course.html">
            
                    
                    交易一致的由来
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../state/state-settle.html">
            
                <a href="../state/state-settle.html">
            
                    
                    qilu-state使用说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../state/state-demo.html">
            
                <a href="../state/state-demo.html">
            
                    
                    购买订单的处理示例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../backSample/backSampleReadme.html">
            
                <a href="../backSample/backSampleReadme.html">
            
                    
                    后台代码模板
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../backSample/security.html">
            
                <a href="../backSample/security.html">
            
                    
                    安全介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../backSample/deploy.html">
            
                <a href="../backSample/deploy.html">
            
                    
                    部署集成
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../backSample/config.html">
            
                <a href="../backSample/config.html">
            
                    
                    spring配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../backSample/sso.html">
            
                <a href="../backSample/sso.html">
            
                    
                    SSO集成
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../backSample/example.html">
            
                <a href="../backSample/example.html">
            
                    
                    常见代码示例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../test/readme.html">
            
                <a href="../test/readme.html">
            
                    
                    关于测试
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../test/unitTest.html">
            
                <a href="../test/unitTest.html">
            
                    
                    单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../test/function.html">
            
                <a href="../test/function.html">
            
                    
                    功能测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../test/noFunction.html">
            
                <a href="../test/noFunction.html">
            
                    
                    非功能测试
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../video/test.html">
            
                <a href="../video/test.html">
            
                    
                    视频
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../video/build.html">
            
                <a href="../video/build.html">
            
                    
                    项目构建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../video/state.html">
            
                <a href="../video/state.html">
            
                    
                    交易一致
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >qilu-mybatis</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="qilu-mybatis&#x4ECB;&#x7ECD;">qilu-mybatis&#x4ECB;&#x7ECD;</h1>
<p>&#x5728;&#x5F00;&#x6E90;&#x9886;&#x57DF;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;pageHelper,mybatis-plus&#x7684;&#x60C5;&#x51B5;&#x4E0B;,&#x4E3A;&#x5565;&#x8FD8;&#x8981;&#x5F00;&#x53D1;qilu-mybatis????</p>
<p>&#x4E3B;&#x8981;&#x662F;&#x6211;&#x6709;&#x504F;&#x89C1;,&#x6211;&#x4EEC;&#x8BA4;&#x4E3A;&#x5728;pageHelper&#x548C;mybatis-plus&#x4E4B;&#x5916;,&#x8FD8;&#x6709;&#x4E00;&#x79CD;&#x66F4;&#x597D;&#x7528;&#x7684;mybatis&#x7684;&#x4F7F;&#x7528;&#x65B9;&#x5F0F;.&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x5728;&#x4E8E;&#x5728;mybatis-generator-tool&#x81EA;&#x52A8;&#x751F;&#x6210;&#x7684;&#x5404;&#x79CD;&#x64CD;&#x4F5C;&#x592A;&#x597D;&#x7528;&#x4E86;,&#x4EE5;&#x81F3;&#x4E8E;&#x6211;&#x8BA4;&#x4E3A;&#x53EF;&#x4EE5;&#x629B;&#x5F03;pageHelper&#x548C;mybatis-plus&#x5E26;&#x6765;&#x7684;&#x4FBF;&#x5229;,&#x800C;&#x4E00;&#x5B9A;&#x8981;&#x96C6;&#x6210;mybatis-generator&#x7684;&#x751F;&#x6210;&#x7C7B;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x4F7F;&#x7528;mybatis.</p>
<p>qilu-mybaits&#x4E3B;&#x8981;&#x7279;&#x6027;</p>
<ol>
<li>&#x652F;&#x6301;&#x4E0D;&#x540C;&#x6570;&#x636E;&#x5E93;<ul>
<li>&#x7279;&#x522B;&#x662F;&#x5E38;&#x89C1;&#x7684;&#x5206;&#x9875;,&#x4E3B;&#x952E;&#x7B56;&#x7565;&#x90FD;&#x5B58;&#x5728;&#x5F88;&#x5927;&#x7684;&#x5DEE;&#x5F02;</li>
</ul>
</li>
<li>mybatis-generator&#x7684;&#x96C6;&#x6210;<ul>
<li>mybatis-generator&#x662F;&#x4E00;&#x4E2A;&#x5F88;&#x5F3A;&#x5927;&#x7684;&#x4EE3;&#x7801;&#x751F;&#x6210;&#x5668;,&#x7279;&#x522B;&#x662F;&#x4E2D;&#x95F4;&#x7684;Mapper&#x548C;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x7684;&#x751F;&#x6210;,&#x4F7F;&#x7528;&#x6BD4;&#x8F83;&#x723D;,&#x723D;&#x5230;&#x9700;&#x8981;&#x66FF;&#x6362;pageHelper&#x6216;&#x8005;mybatis-plus</li>
</ul>
</li>
</ol>
<h2 id="&#x4EE3;&#x7801;&#x96C6;&#x6210;">&#x4EE3;&#x7801;&#x96C6;&#x6210;</h2>
<h3 id="qilu-mybatis&#x7684;maven&#x4F9D;&#x8D56;">qilu-mybatis&#x7684;maven&#x4F9D;&#x8D56;</h3>
<pre class="language-"><code class="lang-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.9istock.base<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>qilu-mybatis<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>&#x6700;&#x65B0;&#x7248;&#x672C;<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<h3 id="qilu-generator&#x7684;maven&#x4F9D;&#x8D56;">qilu-generator&#x7684;maven&#x4F9D;&#x8D56;</h3>
<pre class="language-"><code class="lang-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.9istock.base<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>qilu-generator<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>&#x6700;&#x65B0;&#x7248;&#x672C;<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>scope</span><span class="token punctuation">&gt;</span></span>test<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>scope</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<h3 id="&#x4F7F;&#x7528;">&#x4F7F;&#x7528;</h3>
<h4 id="spring&#x914D;&#x7F6E;">spring&#x914D;&#x7F6E;</h4>
<p>&#x5728;spring&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x589E;&#x52A0;mybatis&#x7684;&#x626B;&#x63CF;&#x548C;qilu-mybatis&#x7684;bean</p>
<pre class="language-"><code class="lang-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>org.mybatis.spring.mapper.MapperScannerConfigurer<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>basePackage<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.union.user.dao<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>sqlSessionFactoryBeanName<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>sqlSessionFactory<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>sqlSessionFactory<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>org.mybatis.spring.SqlSessionFactoryBean<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>dataSource<span class="token punctuation">&quot;</span></span> <span class="token attr-name">ref</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>dataSource<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
    <span class="token comment">&lt;!-- &#x81EA;&#x52A8;&#x626B;&#x63CF;mapping.xml&#x6587;&#x4EF6; --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>mapperLocations<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>classpath:unionUser/**/*.xml<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>plugins<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>list</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ref</span> <span class="token attr-name">bean</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>pageInterceptor<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>list</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>
<span class="token comment">&lt;!--&#x62E6;&#x622A;&#x5668;&#x7684;&#x6CE8;&#x5165;--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>pageInterceptor<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.base.mybatis.interceptor.PageInterceptor<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>commonExecutor<span class="token punctuation">&quot;</span></span> <span class="token attr-name">ref</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>commonExecutor<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>commonExecutor<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.base.mybatis.executor.CommonExecutor<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token comment">&lt;!-- &#x53EF;&#x4EE5;&#x4E0D;&#x6307;&#x5B9A;,&#x5E38;&#x89C1;&#x7684;&#x6570;&#x636E;&#x5E93;&#x53EF;&#x4EE5;&#x81EA;&#x52A8;&#x8BC6;&#x522B;,&#x5305;&#x542B;MYSQL,MSSQL,DB2,ORACLE --&gt;</span>
    <span class="token comment">&lt;!-- &lt;property name=&quot;dialect&quot;&gt;
        &lt;bean class=&quot;com.istock.base.mybatis.dialect.MysqlDialect&quot;&gt;&lt;/bean&gt;
    &lt;/property&gt; --&gt;</span>
    <span class="token comment">&lt;!--&#x4E3B;&#x952E;&#x751F;&#x6210;&#x7B56;&#x7565;--&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>keyType<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>MEM18<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token comment">&lt;!--&#x4E0D;&#x540C;&#x7684;&#x8868;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7684;&#x7EC4;&#x4EF6;&#x7B56;&#x7565;--&gt;</span>
    <span class="token comment">&lt;!-- &lt;property name=&quot;tableMap&quot;&gt;
        &lt;map&gt;
            &lt;entry key=&quot;AUTH_AUDIT_LOG&quot;&gt;
                &lt;value&gt;SEQ&lt;/value&gt;
            &lt;/entry&gt;
            &lt;entry key=&quot;TEST_SENVON_INFO&quot;&gt;
                &lt;value&gt;MEM&lt;/value&gt;
            &lt;/entry&gt;
        &lt;/map&gt;
    &lt;/property&gt; --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>

<span class="token comment">&lt;!--&#x7EC4;&#x4EF6;&#x7B56;&#x7565;&#x6CE8;&#x5165;--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>strategyService<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.base.mybatis.strategy.StrategyService<span class="token punctuation">&quot;</span></span> <span class="token attr-name">factory-method</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>getInstance<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>strategySet<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>set</span><span class="token punctuation">&gt;</span></span>
            <span class="token comment">&lt;!--&#x4F9D;&#x8D56;&#x6570;&#x636E;&#x5E93;&#x7684;sequence&#x7B56;&#x7565;&#x751F;&#x6210;&#x4E3B;&#x952E;,&#x652F;&#x6301;Oracle,DB2,SqlServer--&gt;</span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.base.mybatis.strategy.SequenceIdStrategy<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>dataSource<span class="token punctuation">&quot;</span></span> <span class="token attr-name">ref</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>dataSource<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>sequenceNumber<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>30<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>
            <span class="token comment">&lt;!--&#x57FA;&#x4E8E;snowflake&#x7684;&#x5185;&#x5B58;&#x6A21;&#x5F0F;&#x4E0B;&#x7684;&#x4E3B;&#x952E;&#x751F;&#x6210;,&#x652F;&#x6301;&#x6240;&#x6709;&#x6570;&#x636E;&#x5E93;--&gt;</span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.base.mybatis.strategy.SnowFlackStrategy<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>set</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<p>&#x5728;CommonExecutor&#x4E2D;,&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x914D;&#x7F6E;&#x4E0D;&#x540C;&#x7684;&#x6570;&#x636E;&#x5E93;&#x65B9;&#x8A00;,&#x4E00;&#x79CD;&#x652F;&#x6301;4&#x79CD;&#x6570;&#x636E;&#x5E93;&#x65B9;&#x8A00;</p>
<ul>
<li>Mysql: com.istock.base.mybatis.dialect.MysqlDialect</li>
<li>Oracle: com.istock.base.mybatis.dialect.OracleDialect</li>
<li>DB2: com.istock.base.mybatis.dialect.DB2Dialect</li>
<li>MSSQL: com.istock.base.mybatis.dialect.MSSqlDialect</li>
</ul>
<p>&#x5982;&#x679C;commonExecutor&#x4E0D;&#x914D;&#x7F6E;&#x6570;&#x636E;&#x5E93;&#x65B9;&#x8A00;,&#x7CFB;&#x7EDF;&#x5C31;&#x4F1A;&#x5728;&#x542F;&#x52A8;&#x7684;&#x65F6;&#x5019;&#x9ED8;&#x8BA4;&#x4F7F;&#x7528;&#x6570;&#x636E;&#x5E93;&#x4EA7;&#x54C1;&#x8FDB;&#x884C;&#x8BBE;&#x7F6E;</p>
<p>&#x5728;commonExecutor&#x4E2D;,&#x53EF;&#x4EE5;&#x914D;&#x7F6E;&#x4E0D;&#x540C;&#x7684;&#x8868;&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7684;&#x4E3B;&#x952E;&#x7B56;&#x7565;,&#x4E3B;&#x952E;&#x7B56;&#x7565;&#x6709;&#x4E8C;&#x79CD;&#x7C7B;&#x578B;</p>
<ul>
<li>MEM:&#x4F7F;&#x7528;&#x5185;&#x5B58;&#x751F;&#x6210;&#x4E3B;&#x952E;(&#x63A8;&#x8350;&#x4F7F;&#x7528;)</li>
<li>MEM18:&#x4F7F;&#x7528;&#x5185;&#x5B58;&#x751F;&#x6210;18&#x4F4D;&#x6570;&#x5B57;(&#x4F20;&#x7EDF;&#x7684;snowflake&#x6709;&#x65F6;&#x5019;&#x4F1A;&#x751F;&#x6210;19&#x4F4D;&#x6570;&#x5B57;)(&#x63A8;&#x8350;&#x4F7F;&#x7528;)</li>
<li>SEQ:&#x4F7F;&#x7528;&#x6570;&#x636E;&#x5E93;&#x7684;sequence&#x529F;&#x80FD;&#x751F;&#x6210;&#x4E3B;&#x952E;</li>
</ul>
<p>StrategyService,&#x662F;&#x4E3B;&#x952E;&#x7B56;&#x7565;&#x7684;&#x81EA;&#x5B9A;&#x4E49;,&#x53EF;&#x4EE5;&#x652F;&#x6301;&#x4E8C;&#x6B21;&#x5F00;&#x53D1;,&#x9700;&#x8981;&#x5B9E;&#x73B0;com.istock.base.mybatis.strategy.IdStrategy&#x63A5;&#x53E3;</p>
<p>&#x5728;&#x4F7F;&#x7528;qilu-mybatis&#x8FDB;&#x884C;batch,insert&#x64CD;&#x4F5C;&#x65F6;,&#x4E3A;&#x4E86;&#x51CF;&#x5C11;&#x6570;&#x636E;&#x5E93;&#x7684;&#x8BBF;&#x95EE;&#x4F1A;&#x751F;&#x6210;&#x6279;&#x91CF;&#x7684;&#x83B7;&#x53D6;id,&#x5728;&#x8FD9;&#x79CD;&#x6A21;&#x5F0F;&#x4E0B;,&#x65E0;&#x6CD5;&#x652F;&#x6301;&#x81EA;&#x589E;&#x957F;&#x4E3B;&#x952E;&#x7684;&#x751F;&#x6210;.</p>
<p>&#x5728;&#x4F7F;&#x7528;&#x4FEE;&#x6539;&#x540E;&#x7684;qilu-generator&#x7684;&#x57FA;&#x7840;&#x4E0A;,&#x6B63;&#x5E38;&#x751F;&#x6210;mapper&#x548C;pojo&#x7C7B;</p>
<h2 id="&#x4EE3;&#x7801;&#x81EA;&#x52A8;&#x751F;&#x6210;">&#x4EE3;&#x7801;&#x81EA;&#x52A8;&#x751F;&#x6210;</h2>
<p><a href="images/runMybatisTool.png" data-lightbox="822fcede-a951-44ca-9713-e78b61bac4a5" data-title="&#x4EE3;&#x7801;&#x4E2D;&#x7684;&#x4F4D;&#x7F6E;"><img src="images/runMybatisTool.png" alt="&#x4EE3;&#x7801;&#x4E2D;&#x7684;&#x4F4D;&#x7F6E;"></a>
&#x5728;dal&#x5B50;&#x9879;&#x76EE;&#x4E2D;,test/resources/generatorConfig.xml&#x5C31;&#x662F;&#x751F;&#x6210;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;,&#x800C;test/java&#x91CC;&#x9762;&#x7684;MybatisGeneratorRun.java&#x5219;&#x662F;&#x8FD0;&#x884C;&#x7C7B;.&#x8FD0;&#x884C;&#x8FD9;&#x4E2A;&#x7C7B;,&#x4F1A;&#x81EA;&#x52A8;&#x52A0;&#x8F7D;generatorConfig.xml&#x4E2D;&#x7684;&#x914D;&#x7F6E;,&#x6309;&#x7167;&#x914D;&#x7F6E;&#x751F;&#x6210;&#x5BF9;&#x5E94;&#x7684;java&#x6620;&#x5C04;.</p>
<h3 id="&#x751F;&#x6210;&#x5DE5;&#x5177;&#x7684;maven&#x4F9D;&#x8D56;">&#x751F;&#x6210;&#x5DE5;&#x5177;&#x7684;maven&#x4F9D;&#x8D56;</h3>
<pre class="language-"><code class="lang-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.9istock.base<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>qilu-generator<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<h3 id="&#x914D;&#x7F6E;">&#x914D;&#x7F6E;</h3>
<pre class="language-"><code class="lang-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>context</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>OracleTables<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetRuntime</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>MyBatis3<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>plugin</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>org.mybatis.generator.plugins.ToStringPlugin<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>plugin</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>plugin</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>org.mybatis.generator.plugins.EqualsHashCodePlugin<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>plugin</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>plugin</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.generator.plugin.TopSerializablePlugin<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>plugin</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>plugin</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.generator.plugin.SqlMapUnMergePlugin<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>plugin</span><span class="token punctuation">&gt;</span></span>
<span class="token comment">&lt;!-- DAO&#x7684;&#x751F;&#x6210;,&#x5E26;&#x6709;&#x5206;&#x9875;&#x6807;&#x8BC6; --&gt;</span>
<span class="token comment">&lt;!-- &#x751F;&#x6210;mybatis --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>plugin</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.generator.plugin.MybatisPagePlugin<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>pageClass<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.base.common.api.model.PageInfo<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>plugin</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>commentGenerator</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.generator.plugin.DBCommentGenerator<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>suppressAllComments<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>commentGenerator</span><span class="token punctuation">&gt;</span></span>

<span class="token comment">&lt;!-- &lt;jdbcConnection driverClass=&quot;oracle.jdbc.driver.OracleDriver&quot; connectionURL=&quot;jdbc:oracle:thin:@101.200.228.39:1521:vfinance&quot;
    userId=&quot;test&quot; password=&quot;123&quot;&gt;
    &lt;property name=&quot;remarksReporting&quot; value=&quot;true&quot; /&gt;
&lt;/jdbcConnection&gt; --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>jdbcConnection</span> <span class="token attr-name">driverClass</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>org.gjt.mm.mysql.Driver<span class="token punctuation">&quot;</span></span> <span class="token attr-name">connectionURL</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>jdbc:mysql://senvon.vm:3306/new-user?useUnicode=true<span class="token entity" title="&amp;">&amp;amp;</span>characterEncoding=UTF-8<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name">userId</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>root<span class="token punctuation">&quot;</span></span> <span class="token attr-name">password</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>123<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>remarksReporting<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>jdbcConnection</span><span class="token punctuation">&gt;</span></span>

<span class="token comment">&lt;!-- POJO&#x7C7B;&#x751F;&#x6210;&#x914D;&#x7F6E; --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>javaModelGenerator</span> <span class="token attr-name">targetPackage</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.union.user.model<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetProject</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>../back-sample-dal/src/main/java<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>trimStrings<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>javaModelGenerator</span><span class="token punctuation">&gt;</span></span>

<span class="token comment">&lt;!-- SqlMap&#x6587;&#x4EF6;&#x751F;&#x6210;&#x914D;&#x7F6E; --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sqlMapGenerator</span> <span class="token attr-name">targetPackage</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>unionUser<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetProject</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>../back-sample-dal/src/main/resources<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>sqlMapGenerator</span><span class="token punctuation">&gt;</span></span>

<span class="token comment">&lt;!-- Dao&#x751F;&#x6210;&#x914D;&#x7F6E; --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>javaClientGenerator</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>XMLMAPPER<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetPackage</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.union.user.dao<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetProject</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>../back-sample-dal/src/main/java<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>javaClientGenerator</span><span class="token punctuation">&gt;</span></span>

<span class="token comment">&lt;!-- &#x6570;&#x636E;&#x5E93;&#x8868; --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>table</span> <span class="token attr-name">tableName</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>SYS_TENANT_INFO<span class="token punctuation">&quot;</span></span> <span class="token attr-name">domainObjectName</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>TenantInfo<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>generatedKey</span> <span class="token attr-name">column</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>ID<span class="token punctuation">&quot;</span></span> <span class="token attr-name">sqlStatement</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>GENID(&apos;SYS_TENANT_INFO&apos;)<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>table</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<p>&#x8FD0;&#x884C;MybatisGeneratorRun,&#x6765;&#x5F97;&#x5230;&#x751F;&#x6210;&#x7684;&#x4EE3;&#x7801;.&#x53EF;&#x4EE5;&#x5728;user-dal/test/...&#x4E0B;&#x627E;&#x5230;</p>
<blockquote>
<p>[!WARNING]</p>
<ol>
<li>&#x88AB;&#x751F;&#x6210;&#x7684;&#x8868;SYS_TENANT_INFO&#x4E2D;,&#x4E00;&#x5B9A;&#x8981;&#x5728;&#x6570;&#x636E;&#x5E93;&#x5C42;&#x9762;&#x8BBE;&#x7F6E;&#x5355;&#x5B57;&#x6BB5;&#x4E3B;&#x952E;.&#x5982;&#x679C;&#x8868;&#x4E0D;&#x5B58;&#x5728;&#x4E3B;&#x952E;,&#x5219;&#x4E0D;&#x4F1A;&#x751F;&#x6210;SelectByKey,updateByKey&#x7684;&#x4E00;&#x4E9B;&#x64CD;&#x4F5C;,&#x5982;&#x679C;&#x8868;&#x4E2D;&#x5B58;&#x5728;&#x8054;&#x5408;&#x4E3B;&#x952E;,&#x5C31;&#x4F1A;&#x751F;&#x6210;&#x989D;&#x5916;&#x7684;&#x4E3B;&#x952E;&#x67E5;&#x8BE2;.</li>
<li>generatedKey&#x7684;sqlStatement,&#x8FD9;&#x4E2A;&#x5B57;&#x6BB5;&#x662F;&#x4E00;&#x4E2A;&#x8868;&#x8FBE;&#x5F0F;,qilu-mybatis&#x901A;&#x8FC7;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5904;&#x7406;,&#x52A0;&#x8F7D;&#x4E0D;&#x540C;&#x7684;&#x4E3B;&#x952E;&#x7B56;&#x7565;.&#x8FD9;&#x8FB9;&#x53EF;&#x4EE5;&#x914D;&#x7F6E;&#x4E3A;&#x6BD4;&#x5982;Date  +  &apos;TB&apos;+  GENID  (  &apos;TEST_TASK_INFO&apos;  )    &#x8FD9;&#x5C31;&#x4EE3;&#x8868;&#x4F7F;&#x7528;&#x5F53;&#x524D;&#x7684;&#x65E5;&#x671F;+TB+&#x4E3B;&#x952E;&#x7B56;&#x7565;&#x7684;&#x6570;&#x5B57;&#x7EC4;&#x6210;&#x4E00;&#x4E2A;&#x4E3B;&#x952E;.</li>
<li>&#x6240;&#x6709;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x7684;&#x4EE3;&#x7801;&#x4E0D;&#x662F;&#x62FF;&#x6765;&#x4FEE;&#x6539;&#x7684;,&#x800C;&#x662F;&#x62FF;&#x6765;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x7684;,&#x8BF7;&#x4E0D;&#x8981;&#x4FEE;&#x6539;&#x4EFB;&#x4F55;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x7684;&#x4EE3;&#x7801;,&#x5426;&#x5219;&#x6570;&#x636E;&#x5E93;&#x53D8;&#x66F4;&#x7684;&#x65F6;&#x5019;,&#x4FEE;&#x6539;&#x7684;&#x90A3;&#x4E9B;&#x4EE3;&#x7801;&#x5C06;&#x4F1A;&#x88AB;&#x8986;&#x76D6;</li>
<li>&#x672C;&#x5DE5;&#x5177;&#x53EA;&#x662F;&#x5BF9;&#x539F;&#x672C;&#x7684;mybatis-generator-tool&#x7684;&#x589E;&#x5F3A;,&#x5728;&#x751F;&#x6210;mapper,Example&#x7684;&#x65F6;&#x5019;,&#x589E;&#x52A0;&#x4E86;&#x90E8;&#x5206;&#x5185;&#x5BB9;,&#x539F;&#x672C;mybatis-generator-tool&#x7684;&#x914D;&#x7F6E;&#x4F9D;&#x65E7;&#x751F;&#x6548;.</li>
</ol>
</blockquote>
<h3 id="&#x4F7F;&#x7528;&#x8303;&#x4F8B;">&#x4F7F;&#x7528;&#x8303;&#x4F8B;</h3>
<h4 id="&#x5206;&#x9875;&#x67E5;&#x8BE2;">&#x5206;&#x9875;&#x67E5;&#x8BE2;</h4>
<pre class="language-"><code class="lang-java"><span class="token class-name">AuditLogExample</span> example <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">AuditLogExample</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">AuditLogExample</span><span class="token punctuation">.</span><span class="token class-name">Criteria</span> criteria <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">createCriteria</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
criteria<span class="token punctuation">.</span><span class="token function">andSrcIdLike</span><span class="token punctuation">(</span><span class="token string">&quot;%2017%&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Long</span><span class="token punctuation">&gt;</span></span> idList <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Long</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
idList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token number">10L</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
idList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token number">11L</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
criteria<span class="token punctuation">.</span><span class="token function">andIdIn</span><span class="token punctuation">(</span>idList<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">PageInfo</span> page <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">PageInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">AuditLog</span><span class="token punctuation">&gt;</span></span> logList <span class="token operator">=</span> auditLogMapper<span class="token punctuation">.</span><span class="token function">selectByExample</span><span class="token punctuation">(</span>example<span class="token punctuation">,</span> page<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h4 id="top&#x67E5;&#x8BE2;">top&#x67E5;&#x8BE2;</h4>
<pre class="language-"><code class="lang-java">&#x4F7F;&#x7528;&#x5206;&#x9875;&#x7684;api<span class="token punctuation">,</span>&#x4E0D;&#x518D;&#x8FDB;&#x884C;count&#x7EDF;&#x8BA1;
<span class="token class-name">AuditLogExample</span> example <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">AuditLogExample</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">AuditLogExample</span><span class="token punctuation">.</span><span class="token class-name">Criteria</span> criteria <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">createCriteria</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
criteria<span class="token punctuation">.</span><span class="token function">andSrcIdLike</span><span class="token punctuation">(</span><span class="token string">&quot;%2017%&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">PageInfo</span> page <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">PageInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
page<span class="token punctuation">.</span><span class="token function">setNeedCount</span><span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">AuditLog</span><span class="token punctuation">&gt;</span></span> logList <span class="token operator">=</span> auditLogMapper<span class="token punctuation">.</span><span class="token function">selectByExample</span><span class="token punctuation">(</span>example<span class="token punctuation">,</span> page<span class="token punctuation">)</span><span class="token punctuation">;</span>
logger<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;pageNo:{} , pageTotal:{} &quot;</span> <span class="token punctuation">,</span><span class="token keyword">new</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span> page<span class="token punctuation">.</span><span class="token function">getLimit</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>page<span class="token punctuation">.</span><span class="token function">getTotalPage</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
logger<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;logListSize:{}&quot;</span><span class="token punctuation">,</span>logList<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h4 id="&#x4E50;&#x89C2;&#x9501;&#x66F4;&#x65B0;">&#x4E50;&#x89C2;&#x9501;&#x66F4;&#x65B0;</h4>
<pre class="language-"><code class="lang-java"><span class="token class-name">AuditLogExample</span> example <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">AuditLogExample</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">AuditLogExample</span><span class="token punctuation">.</span><span class="token class-name">Criteria</span> criteria <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">createCriteria</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
criteria<span class="token punctuation">.</span><span class="token function">andIdEqualTo</span><span class="token punctuation">(</span><span class="token number">10L</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
criteria<span class="token punctuation">.</span><span class="token function">andOrgIdGreaterThanOrEqualTo</span><span class="token punctuation">(</span><span class="token string">&quot;123&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">AuditLog</span> updateRecord <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">AuditLog</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
updateRecord<span class="token punctuation">.</span><span class="token function">setIp</span><span class="token punctuation">(</span><span class="token string">&quot;senvon&apos;s ip&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
auditLogMapper<span class="token punctuation">.</span><span class="token function">updateByExampleSelective</span><span class="token punctuation">(</span>updateRecord<span class="token punctuation">,</span> example<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x5E26;&#x6761;&#x4EF6;&#x7684;&#x6279;&#x91CF;&#x66F4;&#x65B0;,&#x751F;&#x6210;&#x7684;&#x4EE3;&#x7801;&#x63D0;&#x4F9B;3&#x79CD;&#x66F4;&#x65B0;,updatebyExample,updateByKey&#x548C;updateBySelective</p>
<ul>
<li>updatebyExample,&#x5982;&#x679C;&#x4F20;&#x5165;&#x5B57;&#x6BB5;&#x4E3A;&#x7A7A;,&#x5219;&#x63D2;&#x5165;null</li>
<li>UpdateByKey,&#x901A;&#x8FC7;&#x4E3B;&#x952E;&#x66F4;&#x65B0;</li>
<li>UpdateBySelective,&#x5982;&#x679C;&#x4F20;&#x5165;&#x5B57;&#x6BB5;&#x4E3A;&#x7A7A;,&#x5219;&#x4E0D;&#x751F;&#x6210;&#x8BE5;&#x5B57;&#x6BB5;&#x7684;&#x66F4;&#x65B0;&#x8BED;&#x53E5;</li>
</ul>
<h4 id="&#x6279;&#x91CF;&#x5904;&#x7406;">&#x6279;&#x91CF;&#x5904;&#x7406;</h4>
<pre class="language-"><code class="lang-java"><span class="token annotation punctuation">@Autowired</span>
<span class="token keyword">private</span> <span class="token class-name">SqlSessionFactoryBean</span> sessionFactory<span class="token punctuation">;</span>

<span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span><span class="token punctuation">{</span>
    <span class="token class-name">SqlSession</span> session <span class="token operator">=</span> sessionFactory<span class="token punctuation">.</span><span class="token function">getObject</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">openSession</span><span class="token punctuation">(</span><span class="token class-name">ExecutorType</span><span class="token punctuation">.</span>BATCH<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">AuditLogMapper</span> auditLogMapper <span class="token operator">=</span> session<span class="token punctuation">.</span><span class="token function">getMapper</span><span class="token punctuation">(</span><span class="token class-name">AuditLogMapper</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span><span class="token number">0</span> <span class="token punctuation">;</span> i<span class="token operator">&lt;</span><span class="token number">100</span> <span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">AuditLog</span> auditLog <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">AuditLog</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        auditLog<span class="token punctuation">.</span><span class="token function">setIp</span><span class="token punctuation">(</span><span class="token string">&quot;senvon&apos;s ip&quot;</span><span class="token operator">+</span>i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        auditLog<span class="token punctuation">.</span><span class="token function">setOrgId</span><span class="token punctuation">(</span><span class="token string">&quot;org ip &quot;</span><span class="token operator">+</span>i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        auditLog<span class="token punctuation">.</span><span class="token function">setReqParams</span><span class="token punctuation">(</span><span class="token string">&quot;params &quot;</span><span class="token operator">+</span>i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        auditLog<span class="token punctuation">.</span><span class="token function">setRootOrgId</span><span class="token punctuation">(</span><span class="token string">&quot;root--&quot;</span><span class="token operator">+</span>i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        auditLog<span class="token punctuation">.</span><span class="token function">setSrcId</span><span class="token punctuation">(</span><span class="token string">&quot;srcId&quot;</span><span class="token operator">+</span>i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        auditLog<span class="token punctuation">.</span><span class="token function">setStatus</span><span class="token punctuation">(</span><span class="token string">&quot;s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        auditLog<span class="token punctuation">.</span><span class="token function">setUserId</span><span class="token punctuation">(</span><span class="token string">&quot;uid&quot;</span><span class="token operator">+</span>i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        auditLog<span class="token punctuation">.</span><span class="token function">setVisitDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        auditLog<span class="token punctuation">.</span><span class="token function">setVisitUrl</span><span class="token punctuation">(</span><span class="token string">&quot;url&quot;</span><span class="token operator">+</span>i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        auditLogMapper<span class="token punctuation">.</span><span class="token function">insertSelective</span><span class="token punctuation">(</span>auditLog<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    session<span class="token punctuation">.</span><span class="token function">flushStatements</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    session<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5728;&#x4E2D;&#x95F4;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x591A;&#x4E2A;mapper&#x7684;&#x5904;&#x7406;.</p>
<blockquote>
<p>[!DANGER]
&#x5982;&#x679C;&#x6279;&#x91CF;&#x5904;&#x7406;&#x91CC;&#x9762;&#x51FA;&#x73B0;&#x591A;&#x4E2A;mapper&#x7684;&#x8C03;&#x7528;,&#x662F;&#x4E0D;&#x5F71;&#x54CD;&#x6279;&#x5904;&#x7406;&#x7684;&#x6267;&#x884C;,&#x4F46;&#x662F;&#x4F1A;&#x5F71;&#x54CD;&#x5177;&#x4F53;sql&#x7684;&#x6267;&#x884C;&#x987A;&#x5E8F;,mybatis&#x4F1A;&#x628A;&#x76F8;&#x540C;&#x7684;sql&#x653E;&#x5728;&#x4E00;&#x4E2A;&#x8BF7;&#x6C42;&#x91CC;&#x9762;&#x63D0;&#x4EA4;</p>
</blockquote>
<h4 id="&#x6A21;&#x677F;&#x8868;&#x5206;&#x8868;&#x7684;&#x64CD;&#x4F5C;">&#x6A21;&#x677F;&#x8868;/&#x5206;&#x8868;&#x7684;&#x64CD;&#x4F5C;</h4>
<p>&#x5728;&#x5F00;&#x53D1;&#x5E94;&#x7528;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;,&#x96BE;&#x514D;&#x4F1A;&#x4F7F;&#x7528;&#x5230;&#x6A21;&#x677F;&#x8868;,&#x9488;&#x5BF9;&#x67D0;&#x4E00;&#x4E2A;&#x7279;&#x5B9A;&#x7684;&#x503C;,&#x8BBF;&#x95EE;&#x7279;&#x5B9A;&#x7684;&#x8868;,&#x6BD4;&#x5982;XX_TABLE_NAME_2020,XX_TABLE_NAME_2019.&#x5F88;&#x660E;&#x663E;,&#x8FD9;&#x79CD;&#x793A;&#x4F8B;&#x5C31;&#x662F;&#x6309;&#x7167;&#x5E74;&#x4EFD;&#x8FDB;&#x884C;&#x7684;&#x5206;&#x8868;&#x64CD;&#x4F5C;,&#x8868;&#x7684;&#x5B57;&#x6BB5;&#x90FD;&#x662F;&#x4E00;&#x6837;&#x7684;.</p>
<p>qiluMybatis&#x7684;&#x4EE3;&#x7801;&#x81EA;&#x52A8;&#x751F;&#x6210;,&#x8BA9;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x7684;mapper&#x548C;example,&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x4E8E;&#x6A21;&#x677F;&#x8868;,&#x63D0;&#x4F9B;&#x66F4;&#x52A0;&#x4FBF;&#x6377;&#x7684;&#x64CD;&#x4F5C;.</p>
<p>&#x5047;&#x8BBE;&#x6A21;&#x677F;&#x8868;&#x662F;TEST_MODEL_TABLE_2021,&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x505A;&#x5982;&#x4E0B;&#x64CD;&#x4F5C;:</p>
<ul>
<li>&#x5728;&#x6D4B;&#x8BD5;&#x6570;&#x636E;&#x5E93;&#x65B0;&#x5EFA;&#x8868;,&#x8868;&#x540D;&#x4E3A;<code>TEST_MODEL_TABLE_$CREATE_YEAR$</code>,&#x4E00;&#x5B9A;&#x8981;&#x5728;&#x7269;&#x7406;&#x7684;&#x6570;&#x636E;&#x5E93;&#x4E0A;&#x65B0;&#x5EFA;&#x8868;,&#x4E14;&#x8868;&#x540D;&#x4E2D;&#x7684;&#x6A21;&#x677F;&#x4FE1;&#x606F;,&#x8981;&#x4F7F;&#x7528;$$&#x8FDB;&#x884C;&#x95ED;&#x5305;&#x5904;&#x7406;.&#x751F;&#x4EA7;&#x5E93;&#x4E0A;&#x65E0;&#x987B;&#x521B;&#x5EFA;.<strong style="color:red">&#x5206;&#x8868;&#x952E;&#x9700;&#x8981;&#x5728;&#x8868;&#x5B57;&#x6BB5;&#x4E2D;&#x5B58;&#x5728;,&#x5426;&#x5219;insert&#x64CD;&#x4F5C;&#x4F1A;&#x5931;&#x8D25;</strong>.</li>
<li>&#x6B63;&#x5E38;&#x4F7F;&#x7528;generate.xml&#x914D;&#x7F6E;,&#x751F;&#x6210;mapper,&#x914D;&#x7F6E;&#x7C7B;&#x4F3C;&#x8FD9;&#x6837;
<a href="images/mybatis-model.PNG" data-lightbox="390e63b9-67fb-48ce-8542-63fd06ac714f" data-title="&#x793A;&#x4F8B;"><img src="images/mybatis-model.PNG" alt="&#x793A;&#x4F8B;"></a></li>
<li>&#x5728;&#x4F7F;&#x7528;example&#x7684;&#x65F6;&#x5019;,&#x8BB0;&#x5F97;&#x5BF9;<code>createYear</code>&#x5B57;&#x6BB5;&#x8FDB;&#x884C;&#x8BBE;&#x7F6E;,&#x4E00;&#x5B9A;&#x8981;&#x8BBE;&#x7F6E;&#x8BE5;&#x5B57;&#x6BB5;,&#x5426;&#x5219;&#x6267;&#x884C;&#x4F1A;&#x62A5;&#x9519;</li>
</ul>
<p>&#x4F7F;&#x7528;&#x6B63;&#x5E38;&#x7684;example&#x8FDB;&#x884C;&#x64CD;&#x4F5C;</p>
<pre class="language-"><code class="lang-java"><span class="token class-name">ModelTable</span> update <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ModelTable</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
update<span class="token punctuation">.</span><span class="token function">setAge</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
update<span class="token punctuation">.</span><span class="token function">setCreateYear</span><span class="token punctuation">(</span><span class="token number">2021</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
update<span class="token punctuation">.</span><span class="token function">setName</span><span class="token punctuation">(</span><span class="token string">&quot;aaa&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
update<span class="token punctuation">.</span><span class="token function">setId</span><span class="token punctuation">(</span>lastId<span class="token punctuation">)</span><span class="token punctuation">;</span>
mapper<span class="token punctuation">.</span><span class="token function">updateByPrimaryKey</span><span class="token punctuation">(</span>update<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token class-name">ModelTableExample</span> example <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ModelTableExample</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">ModelTableExample</span><span class="token punctuation">.</span><span class="token class-name">Criteria</span> criteria <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">createCriteria</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
example<span class="token punctuation">.</span><span class="token function">setCreateYear</span><span class="token punctuation">(</span><span class="token string">&quot;2021&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
criteria<span class="token punctuation">.</span><span class="token function">andNameLike</span><span class="token punctuation">(</span><span class="token string">&quot;%senvon%&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">//&#x6BCF;&#x9875;&#x53D6;2&#x6761;</span>
<span class="token class-name">PageInfo</span> pageInfo <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">PageInfo</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ModelTable</span><span class="token punctuation">&gt;</span></span> tableList <span class="token operator">=</span> mapper<span class="token punctuation">.</span><span class="token function">selectByExample</span><span class="token punctuation">(</span>example<span class="token punctuation">,</span> pageInfo<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x5982;&#x679C;&#x4E0A;&#x8FF0;createYear=2021,&#x6700;&#x7EC8;&#x751F;&#x6210;&#x7684;sql&#x8BBF;&#x95EE;&#x7684;&#x8868;&#x4E3A;TEST_MODEL_TABLE_2021</p>
<h3 id="&#x81EA;&#x5B9A;&#x4E49;sql">&#x81EA;&#x5B9A;&#x4E49;SQL</h3>
<h4 id="&#x81EA;&#x5B9A;&#x4E49;sql&#x4F7F;&#x7528;&#x5206;&#x9875;">&#x81EA;&#x5B9A;&#x4E49;sql&#x4F7F;&#x7528;&#x5206;&#x9875;</h4>
<p>&#x751F;&#x6210;&#x5DE5;&#x5177;&#x7684;&#x7406;&#x5FF5;,<strong style="color:red">&#x4E0D;&#x8981;&#x52A8;&#x751F;&#x6210;&#x7684;&#x4E1C;&#x897F;,&#x800C;&#x4E0D;&#x662F;&#x4FEE;&#x6539;</strong></p>
<p>&#x81EA;&#x5B9A;&#x4E49;&#x7684;sql,Mapper&#x63A5;&#x53E3;&#x5B9A;&#x4E49;&#x5728;dao.ext&#x4E2D;,Sql&#x6587;&#x4EF6;&#x521B;&#x5EFA;&#x5728;mapper/ext&#x4E2D;</p>
<p><a href="images/extendsql.png" data-lightbox="34197a36-95a9-4fea-a03a-709ab14961c7" data-title="&#x81EA;&#x5B9A;&#x4E49;sql"><img src="images/extendsql.png" alt="&#x81EA;&#x5B9A;&#x4E49;sql"></a>
&#x5728;&#x81EA;&#x5B9A;&#x4E49;sql&#x4E0B;&#x7684;&#x5206;&#x9875;&#x67E5;&#x8BE2;</p>
<pre class="language-"><code class="lang-java"><span class="token keyword">public</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">UserInfoVO</span><span class="token punctuation">&gt;</span></span> <span class="token function">selectUserListByPage</span><span class="token punctuation">(</span><span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span> <span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> param <span class="token punctuation">,</span> <span class="token class-name">PageInfo</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">UserInfoVO</span><span class="token punctuation">&gt;</span></span> page<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>sql&#x8BED;&#x53E5;&#x5982;&#x4E0B;</p>
<pre class="language-"><code class="lang-xml"> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>select</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>selectUserListByPage<span class="token punctuation">&quot;</span></span> <span class="token attr-name">resultMap</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>BaseResultMap<span class="token punctuation">&quot;</span></span> <span class="token attr-name">parameterType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>java.util.HashMap<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    SELECT
        U.ID, U.TENANT_CODE, U.DEPT_CODE, U.LOGIN_NAME, U.USER_NAME, U.EMAIL, U.PHONE_NUMBER, U.SEX, 
    U.PASSWORD, U.SALT, U.STATUS, U.CREATE_BY, U.CREATE_TIME, U.UPDATE_BY, U.UPDATE_TIME, 
    U.REMARK,T.TENANT_NAME
    , D.DEPT_NAME
    FROM SYS_USER_INFO U LEFT JOIN SYS_DEPT_INFO D ON U.DEPT_CODE = D.DEPT_CODE
    LEFT JOIN SYS_TENANT_INFO T ON U.TENANT_CODE = T.TENANT_CODE
    WHERE LOGIN_NAME != &apos;admin&apos; 
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>trim</span> <span class="token attr-name">prefix</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>AND<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>if</span> <span class="token attr-name">test</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>loginName != null and loginName != &apos;&apos;<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            U.LOGIN_NAME LIKE #{loginName}
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>if</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>if</span> <span class="token attr-name">test</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>status != null<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            U.STATUS = #{status}
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>if</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>if</span> <span class="token attr-name">test</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>phoneNumber != null and phoneNumber != &apos;&apos;<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            U.PHONE_NUMBER LIKE #{phoneNumber}
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>if</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>if</span> <span class="token attr-name">test</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>beginTime != null<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token comment">&lt;!-- &#x5F00;&#x59CB;&#x65F6;&#x95F4;&#x68C0;&#x7D22; --&gt;</span>
            U.CREATE_TIME <span class="token entity" title="&gt;">&amp;gt;</span>= #{beginTime}
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>if</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>if</span> <span class="token attr-name">test</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>endTime != null<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token comment">&lt;!-- &#x7ED3;&#x675F;&#x65F6;&#x95F4;&#x68C0;&#x7D22; --&gt;</span>
            U.CREATE_TIME <span class="token entity" title="&lt;">&amp;lt;</span>= #{endTime}
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>if</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>if</span> <span class="token attr-name">test</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>deptCode != null and deptCode.size()&gt;0<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            U.DEPT_CODE IN
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>foreach</span> <span class="token attr-name">collection</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>deptCode<span class="token punctuation">&quot;</span></span> <span class="token attr-name">index</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>index<span class="token punctuation">&quot;</span></span> <span class="token attr-name">item</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>item<span class="token punctuation">&quot;</span></span> <span class="token attr-name">open</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>(<span class="token punctuation">&quot;</span></span> <span class="token attr-name">separator</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>,<span class="token punctuation">&quot;</span></span> <span class="token attr-name">close</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>)<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
                #{item}
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>foreach</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>if</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>trim</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>if</span> <span class="token attr-name">test</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>orderByClause != null<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        ORDER BY ${orderByClause}
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>if</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>select</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<p>&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x5206;&#x9875;&#x67E5;&#x8BE2;&#x58F0;&#x660E;,&#x63A5;&#x53E3;&#x53C2;&#x6570;&#x4E2D;,<strong style="color:red">&#x8BF7;&#x5305;&#x542B;PageInfo&#x5BF9;&#x8C61;</strong>,&#x5728;&#x8C03;&#x7528;&#x8FC7;&#x7A0B;&#x4E2D;,&#x4E0D;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x4EFB;&#x4F55;&#x5206;&#x9875;&#x7684;&#x8BED;&#x53E5;,&#x81EA;&#x52A8;&#x62E6;&#x622A;&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x81EA;&#x52A8;&#x62FC;&#x63A5;&#x4E0A;&#x914D;&#x7F6E;&#x6570;&#x636E;&#x5E93;&#x65B9;&#x8A00;&#x7684;&#x5206;&#x9875;.</p>
<h4 id="&#x6A21;&#x677F;&#x8868;&#x5206;&#x8868;&#x7684;&#x8054;&#x5408;&#x67E5;&#x8BE2;">&#x6A21;&#x677F;&#x8868;/&#x5206;&#x8868;&#x7684;&#x8054;&#x5408;&#x67E5;&#x8BE2;</h4>
<p>&#x4E00;&#x65E6;&#x5206;&#x8868;&#x4EE5;&#x540E;,&#x6709;&#x65F6;&#x5019;&#x9700;&#x8981;&#x5BF9;&#x5206;&#x8868;&#x8FDB;&#x884C;&#x8054;&#x5408;&#x64CD;&#x4F5C;.&#x4E0B;&#x9762;&#x7684;&#x65B9;&#x6CD5;&#x662F;&#x6700;&#x7B80;&#x5355;&#x7684;&#x5B9E;&#x73B0;&#x5206;&#x8868;&#x8054;&#x5408;&#x67E5;&#x8BE2;&#x7684;&#x65B9;&#x6CD5;.</p>
<ol>
<li><p>&#x65B0;&#x5EFA;Example,&#x7EE7;&#x627F;&#x4E4B;&#x524D;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x7684;example(&#x81EA;&#x52A8;&#x751F;&#x6210;&#x7684;&#x7406;&#x5FF5;&#x662F;,&#x81EA;&#x52A8;&#x751F;&#x6210;&#x7684;&#x4EE3;&#x7801;&#x4E0D;&#x52A8;).</p>
<pre class="language-"><code class="lang-java"><span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ExtModelTableExample</span> <span class="token keyword">extends</span> <span class="token class-name">ModelTableExample</span> <span class="token punctuation">{</span>

 <span class="token keyword">private</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> createYearList <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

 <span class="token keyword">public</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> <span class="token function">getCreateYearList</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
     <span class="token keyword">return</span> createYearList<span class="token punctuation">;</span>
 <span class="token punctuation">}</span>

 <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">setCreateYearList</span><span class="token punctuation">(</span><span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> createYearList<span class="token punctuation">)</span> <span class="token punctuation">{</span>
     <span class="token keyword">this</span><span class="token punctuation">.</span>createYearList <span class="token operator">=</span> createYearList<span class="token punctuation">;</span>
 <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
</li>
<li>&#x6309;&#x7167;&#x4EE5;&#x4E0B;&#x65B9;&#x5F0F;,&#x5B9E;&#x73B0;sql&#x7684;&#x914D;&#x7F6E;<pre class="language-"><code class="lang-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>select</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>findUnionTable<span class="token punctuation">&quot;</span></span> <span class="token attr-name">parameterType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.mybatis.user.model.ExtModelTableExample<span class="token punctuation">&quot;</span></span> <span class="token attr-name">resultMap</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.mybatis.user.dao.ModelTableMapper.BaseResultMap<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>foreach</span> <span class="token attr-name">collection</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>createYearList<span class="token punctuation">&quot;</span></span> <span class="token attr-name">item</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>createYearList<span class="token punctuation">&quot;</span></span> <span class="token attr-name">separator</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span> union all <span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
     <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>trim</span> <span class="token attr-name">prefix</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>(<span class="token punctuation">&quot;</span></span> <span class="token attr-name">suffix</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>)<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
         select
         <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>if</span> <span class="token attr-name">test</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>distinct<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
           distinct
         <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>if</span><span class="token punctuation">&gt;</span></span>
         <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>include</span> <span class="token attr-name">refid</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.mybatis.user.dao.ModelTableMapper.Base_Column_List<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
         from TEST_MODEL_TABLE_${createYearList}
         <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>if</span> <span class="token attr-name">test</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>_parameter != null<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
           <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>include</span> <span class="token attr-name">refid</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.istock.mybatis.user.dao.ModelTableMapper.Example_Where_Clause<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
         <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>if</span><span class="token punctuation">&gt;</span></span>
     <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>trim</span><span class="token punctuation">&gt;</span></span>
 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>foreach</span><span class="token punctuation">&gt;</span></span>
 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>if</span> <span class="token attr-name">test</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>orderByClause != null<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
   order by ${orderByClause}
 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>if</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>select</span><span class="token punctuation">&gt;</span></span>
</code></pre>
</li>
<li>&#x4EE3;&#x7801;&#x8C03;&#x7528;<pre class="language-"><code class="lang-java"><span class="token class-name">ExtModelTableExample</span> example <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ExtModelTableExample</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
example<span class="token punctuation">.</span><span class="token function">getCreateYearList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token string">&quot;2021&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
example<span class="token punctuation">.</span><span class="token function">getCreateYearList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token string">&quot;2020&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">ModelTableExample</span><span class="token punctuation">.</span><span class="token class-name">Criteria</span> criteria <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">createCriteria</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
criteria<span class="token punctuation">.</span><span class="token function">andNameLike</span><span class="token punctuation">(</span><span class="token string">&quot;%senvon%&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
example<span class="token punctuation">.</span><span class="token function">setOrderByClause</span><span class="token punctuation">(</span><span class="token string">&quot;CREATE_YEAR DESC&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">PageInfo</span> pageInfo <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">PageInfo</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ModelTable</span><span class="token punctuation">&gt;</span></span> tableList <span class="token operator">=</span> extMapper<span class="token punctuation">.</span><span class="token function">findUnionTable</span><span class="token punctuation">(</span>example<span class="token punctuation">,</span> pageInfo<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
&#x751F;&#x6210;&#x7684;sql&#x8BED;&#x53E5;&#x5982;&#x4E0B;</li>
</ol>
<p>( select ID, NAME, AGE, CREATE_YEAR from TEST_MODEL_TABLE_2021 WHERE ( NAME like ? ) ) union all ( select ID, NAME, AGE, CREATE_YEAR from TEST_MODEL_TABLE_2020 WHERE ( NAME like ? ) ) order by CREATE_YEAR DESC limit 0,2 </p>
<h3 id="&#x975E;&#x5E38;&#x89C4;&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;">&#x975E;&#x5E38;&#x89C4;&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;</h3>
<h4 id="&#x4E8B;&#x52A1;&#x4E0D;&#x751F;&#x6548;&#x7684;&#x6392;&#x67E5;">&#x4E8B;&#x52A1;&#x4E0D;&#x751F;&#x6548;&#x7684;&#x6392;&#x67E5;</h4>
<ol>
<li>&#x68C0;&#x67E5;spring&#x914D;&#x7F6E;&#x6587;&#x4EF6;,&#x662F;&#x5426;&#x6709;<code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">tx:</span>annotation-driven</span> <span class="token punctuation">/&gt;</span></span></code>&#x7684;&#x914D;&#x7F6E;</li>
<li>&#x626B;&#x63CF;&#x53C2;&#x4E0E;&#x4E8B;&#x52A1;&#x7684;&#x7C7B;&#x7684;&#x65F6;&#x5019;,&#x9700;&#x8981;&#x4F7F;&#x7528;listener&#x7684;&#x65B9;&#x5F0F;&#x52A0;&#x8F7D;,&#x4E0D;&#x80FD;&#x4F7F;&#x7528;dispatcher-servlet&#x7684;&#x65B9;&#x5F0F;&#x52A0;&#x8F7D;.&#x8FD9;&#x662F;2&#x79CD;&#x4E0D;&#x540C;&#x7684;spring&#x7684;&#x914D;&#x7F6E;&#x52A0;&#x8F7D;&#x65B9;&#x5F0F;,&#x4F1A;&#x51FA;&#x73B0;&#x76F8;&#x4E92;&#x8986;&#x76D6;&#x7684;&#x60C5;&#x5F62;,&#x4E00;&#x822C;&#x914D;&#x7F6E;dispatcher-serlvet&#x4E0D;&#x626B;&#x63CF;service&#x7C7B;,&#x53EA;&#x626B;&#x63CF;controller&#x7C7B;.</li>
<li>&#x68C0;&#x67E5;&#x629B;&#x51FA;&#x7684;&#x5F02;&#x5E38;,spring&#x53EA;&#x4F1A;&#x5BF9;runtimeException&#x7684;&#x5F02;&#x5E38;&#x505A;&#x56DE;&#x6EDA;&#x5904;&#x7406;,&#x4E00;&#x822C;&#x7684;Exception&#x6CA1;&#x6709;&#x7279;&#x6B8A;&#x58F0;&#x660E;,&#x4E0D;&#x4F1A;&#x56DE;&#x6EDA;</li>
<li>&#x65B9;&#x6CD5;&#x5185;&#x90E8;&#x7684;&#x8C03;&#x7528;,&#x4E0D;&#x4F1A;&#x89E6;&#x53D1;&#x4E8B;&#x52A1;&#x63A7;&#x5236;.&#x4E00;&#x4E2A;&#x7C7B;&#x91CC;&#x9762;,&#x6709;&#x6CA1;&#x6709;&#x4E8B;&#x52A1;&#x7684;methodA&#x65B9;&#x6CD5;,&#x8C03;&#x7528;&#x6709;&#x4E8B;&#x52A1;&#x7684;methodB&#x65B9;&#x6CD5;,methodB&#x4E0A;&#x7684;&#x4E8B;&#x52A1;,&#x4E0D;&#x4F1A;&#x751F;&#x6548;.spring&#x7684;&#x4E8B;&#x52A1;&#x662F;&#x4F7F;&#x7528;&#x62E6;&#x622A;&#x5668;&#x5B9E;&#x73B0;&#x7684;,&#x5728;&#x5B9E;&#x73B0;&#x62E6;&#x622A;&#x5668;&#x662F;&#x4F7F;&#x7528;&#x52A8;&#x6001;&#x4EE3;&#x7406;&#x5B9E;&#x73B0;&#x7684;,&#x4E00;&#x4E2A;&#x7C7B;&#x7684;&#x5185;&#x90E8;&#x8C03;&#x7528;,&#x4E0D;&#x4F1A;&#x89E6;&#x53D1;&#x52A8;&#x6001;&#x4EE3;&#x7406;.</li>
</ol>
<h4 id="&#x65B9;&#x6CD5;&#x5185;&#x90E8;&#x7684;&#x4E8B;&#x52A1;&#x63A7;&#x5236;">&#x65B9;&#x6CD5;&#x5185;&#x90E8;&#x7684;&#x4E8B;&#x52A1;&#x63A7;&#x5236;</h4>
<p>&#x5E38;&#x89C1;&#x63A8;&#x8350;&#x7684;&#x4E8B;&#x52A1;&#x64CD;&#x4F5C;,&#x662F;&#x5728;&#x65B9;&#x6CD5;&#x4E0A;,&#x589E;&#x52A0;@Transactional&#x7684;&#x6CE8;&#x89E3;,&#x8FD9;&#x79CD;&#x7EA7;&#x522B;&#x7684;&#x6CE8;&#x89E3;&#x53EF;&#x4EE5;&#x6709;&#x6548;&#x89E3;&#x51B3;80%&#x4EE5;&#x4E0A;&#x7684;&#x4E1A;&#x52A1;&#x95EE;&#x9898;,&#x800C;&#x4E14;&#x5F88;&#x65B9;&#x4FBF;.&#x4F46;&#x662F;&#x9488;&#x5BF9;&#x6709;&#x4E9B;&#x4E1A;&#x52A1;&#x573A;&#x666F;,&#x6B63;&#x5E38;&#x7684;&#x4E8B;&#x52A1;&#x9700;&#x8981;&#x7EC6;&#x5316;&#x5230;&#x65B9;&#x6CD5;&#x5185;&#x90E8;,&#x624B;&#x52A8;&#x63A7;&#x5236;&#x4E8B;&#x52A1;&#x7684;&#x63D0;&#x4EA4;&#x548C;&#x56DE;&#x6EDA;.</p>
<pre class="language-"><code class="lang-java"><span class="token annotation punctuation">@Autowired</span>
<span class="token keyword">private</span> <span class="token class-name">TransactionTemplate</span> template<span class="token punctuation">;</span>
<span class="token annotation punctuation">@Autowired</span>
<span class="token keyword">private</span> <span class="token class-name">OrgUserDAO</span> orgUserDao<span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token class-name">OrgUser</span> <span class="token function">updateOrg</span><span class="token punctuation">(</span><span class="token keyword">final</span> <span class="token class-name">String</span> key<span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//do something not in the transaction</span>
    <span class="token keyword">return</span> template<span class="token punctuation">.</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">TransactionCallback</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OrgUser</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>

        <span class="token annotation punctuation">@Override</span>
        <span class="token keyword">public</span> <span class="token class-name">OrgUser</span> <span class="token function">doInTransaction</span><span class="token punctuation">(</span><span class="token class-name">TransactionStatus</span> status<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">try</span><span class="token punctuation">{</span>
                <span class="token class-name">OrgUser</span> user <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">OrgUser</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                user<span class="token punctuation">.</span><span class="token function">setId</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span>
                user<span class="token punctuation">.</span><span class="token function">setUserName</span><span class="token punctuation">(</span><span class="token string">&quot;senvonTest&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                orgUserDao<span class="token punctuation">.</span><span class="token function">updateByPrimaryKeySelective</span><span class="token punctuation">(</span>user<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">return</span> orgUserDao<span class="token punctuation">.</span><span class="token function">selectByPrimaryKey</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token keyword">catch</span><span class="token punctuation">(</span><span class="token class-name">Exception</span> e<span class="token punctuation">)</span><span class="token punctuation">{</span>
                status<span class="token punctuation">.</span><span class="token function">setRollbackOnly</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">return</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//do something not in the transaction</span>
<span class="token punctuation">}</span>
</code></pre>
<h4 id="&#x76F4;&#x63A5;&#x4F7F;&#x7528;datasource">&#x76F4;&#x63A5;&#x4F7F;&#x7528;DataSource</h4>
<p>Spring&#x7BA1;&#x7406;&#x4E86;&#x6240;&#x6709;&#x7684;&#x6570;&#x636E;&#x6E90;,&#x5728;&#x5927;&#x90E8;&#x5206;&#x7684;&#x4E1A;&#x52A1;&#x573A;&#x666F;&#x91CC;&#x9762;,&#x6570;&#x636E;&#x6E90;&#x5BF9;&#x4E8E;&#x5E94;&#x7528;&#x7CFB;&#x7EDF;&#x6765;&#x8BF4;,&#x662F;&#x4E00;&#x4E2A;&#x76F8;&#x5BF9;&#x9759;&#x6001;&#x7684;&#x8D44;&#x6E90;.&#x5728;&#x90E8;&#x5206;&#x4E1A;&#x52A1;&#x573A;&#x666F;&#x91CC;&#x9762;,&#x6570;&#x636E;&#x6E90;&#x662F;&#x4E00;&#x4E2A;&#x52A8;&#x6001;&#x7684;&#x8D44;&#x6E90;,&#x5728;&#x90E8;&#x7F72;&#x914D;&#x7F6E;&#x7684;&#x65F6;&#x5019;,&#x65E0;&#x6CD5;&#x5C06;&#x6570;&#x636E;&#x6E90;&#x914D;&#x7F6E;&#x5230;&#x7CFB;&#x7EDF;&#x91CC;&#x9762;
&#x5728;spring&#x7684;&#x7BA1;&#x7406;&#x7684;&#x6570;&#x636E;&#x6E90;&#x4E0B;&#x9762;,&#x4E0D;&#x5141;&#x8BB8;&#x51FA;&#x73B0;&#x624B;&#x52A8;DataSource.getConnection()&#x7684;&#x64CD;&#x4F5C;,&#x4E5F;&#x4E0D;&#x5141;&#x8BB8;&#x51FA;&#x73B0;conn.close()&#x64CD;&#x4F5C;,&#x624B;&#x52A8;&#x64CD;&#x4F5C;&#x6570;&#x636E;&#x6E90;,&#x4F1A;&#x5F15;&#x53D1;&#x6570;&#x636E;&#x6E90;&#x7684;&#x8870;&#x7AED;,&#x4E00;&#x4E2A;&#x88AB;&#x5173;&#x95ED;&#x7684;&#x6570;&#x636E;&#x6E90;,spring&#x6CA1;&#x6709;&#x4FDD;&#x8BC1;&#x4E00;&#x5B9A;&#x662F;&#x8FDE;&#x63A5;&#x72B6;&#x6001;,&#x5728;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7533;&#x8BF7;&#x6570;&#x636E;&#x6E90;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;,&#x5982;&#x679C;&#x6CA1;&#x6709;&#x63A7;&#x5236;&#x597D;,&#x5C31;&#x4F1A;&#x51FA;&#x73B0;&#x6570;&#x636E;&#x6E90;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5DF2;&#x7ECF;&#x5173;&#x95ED;&#x7684;&#x8FDE;&#x63A5;,&#x9020;&#x6210;&#x7CFB;&#x7EDF;&#x5404;&#x79CD;&#x5F02;&#x5E38;
&#x5982;&#x679C;&#x51FA;&#x73B0;&#x8FD9;&#x79CD;&#x60C5;&#x5F62;,&#x8BF7;&#x4F7F;&#x7528;spring&#x63D0;&#x4F9B;&#x7684;JdbcTemplate&#x6216;&#x8005;NamedParameterJdbcTemplate&#x6765;&#x5B9E;&#x73B0;&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;.</p>
<pre class="language-"><code class="lang-java"><span class="token comment">//&#x76F4;&#x63A5;&#x6CE8;&#x5165;&#x6570;&#x636E;&#x6E90;</span>
<span class="token annotation punctuation">@Autowired</span>
<span class="token keyword">private</span> <span class="token class-name">DataSource</span> dataSource<span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OrgUser</span><span class="token punctuation">&gt;</span></span> <span class="token function">findUser</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token class-name">String</span> sql <span class="token operator">=</span> <span class="token string">&quot;SELECT * FROM TB_ORG_USER WHERE USER_NAME LIKE :userName&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//&#x4F7F;&#x7528;JDBCTemplate&#x64CD;&#x4F5C;&#x6570;&#x636E;&#x6E90;</span>
    <span class="token class-name">NamedParameterJdbcTemplate</span> template <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">NamedParameterJdbcTemplate</span><span class="token punctuation">(</span>dataSource<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span> <span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> paramMap <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span> <span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    paramMap<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;userName&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> template<span class="token punctuation">.</span><span class="token function">query</span><span class="token punctuation">(</span>sql<span class="token punctuation">,</span> paramMap<span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">RowMapper</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OrgUser</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token annotation punctuation">@Override</span>
        <span class="token keyword">public</span> <span class="token class-name">OrgUser</span> <span class="token function">mapRow</span><span class="token punctuation">(</span><span class="token class-name">ResultSet</span> rs<span class="token punctuation">,</span> <span class="token keyword">int</span> rowNum<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">SQLException</span> <span class="token punctuation">{</span>
            <span class="token class-name">OrgUser</span> user <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">OrgUser</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            user<span class="token punctuation">.</span><span class="token function">setDeptCode</span><span class="token punctuation">(</span>rs<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;DEPT_CODE&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            user<span class="token punctuation">.</span><span class="token function">setId</span><span class="token punctuation">(</span>rs<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;ID&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            user<span class="token punctuation">.</span><span class="token function">setIdCode</span><span class="token punctuation">(</span>rs<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;ID_CODE&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            user<span class="token punctuation">.</span><span class="token function">setPassword</span><span class="token punctuation">(</span>rs<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;PASSWORD&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            user<span class="token punctuation">.</span><span class="token function">setRemark</span><span class="token punctuation">(</span>rs<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;REMARK&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">return</span> user<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<h4 id="&#x66FF;&#x4EE3;&#x5B58;&#x50A8;&#x8FC7;&#x7A0B;">&#x66FF;&#x4EE3;&#x5B58;&#x50A8;&#x8FC7;&#x7A0B;</h4>
<p><strong style="color:red">&#x65E0;&#x8BBA;&#x662F;&#x6570;&#x636E;&#x5E93;&#x4E0A;&#x7684;function,procedure&#x8FD8;&#x662F;job,&#x7406;&#x8BBA;&#x4E0A;&#x90FD;&#x662F;&#x5C5E;&#x4E8E;&#x6570;&#x636E;&#x5E93;&#x5DE5;&#x5177;,&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x4E0D;&#x5E94;&#x8BE5;&#x89E6;&#x78B0;&#x8FD9;&#x7C7B;&#x5DE5;&#x5177;</strong></p>
<p>&#x6570;&#x636E;&#x5E93;&#x5DE5;&#x5177;&#x6700;&#x5927;&#x7684;&#x597D;&#x5904;&#x662F;&#x76F4;&#x63A5;&#x5728;&#x6570;&#x636E;&#x5E93;&#x4E0A;&#x64CD;&#x4F5C;,&#x907F;&#x514D;&#x5927;&#x7684;&#x6570;&#x636E;&#x91CF;&#x7684;&#x4EA4;&#x4E92;.&#x4F46;&#x662F;&#x4F1A;&#x5360;&#x636E;&#x6570;&#x636E;&#x5E93;&#x7684;CPU,&#x800C;&#x6570;&#x636E;&#x5E93;&#x7684;CPU&#x5728;&#x6574;&#x4E2A;&#x7CFB;&#x7EDF;&#x7FA4;&#x91CC;&#x9762;,&#x662F;&#x6700;&#x73CD;&#x8D35;&#x7684;,&#x6CA1;&#x6709;&#x4E4B;&#x4E00;.</p>
<p>&#x6BD4;&#x5982;&#x6709;&#x8FD9;&#x4E48;&#x4E00;&#x4E2A;&#x573A;&#x666F;,&#x65E5;&#x7EC8;&#x7ED9;&#x6D3B;&#x671F;&#x8D26;&#x6237;&#x8BA1;&#x7B97;&#x5229;&#x606F;.</p>
<p>&#x4E00;&#x4E2A;&#x5F88;&#x7B80;&#x5355;&#x7684;&#x64CD;&#x4F5C;,&#x4F1A;&#x56E0;&#x4E3A;&#x6D3B;&#x671F;&#x8D26;&#x6237;&#x7684;&#x6570;&#x91CF;&#x6210;&#x4E3A;&#x96BE;&#x9898;,&#x5982;&#x679C;&#x6D3B;&#x671F;&#x8D26;&#x6237;&#x5728;1W&#x4EE5;&#x5185;,&#x968F;&#x4FBF;&#x64CD;&#x4F5C;.
&#x4F46;&#x662F;&#x5982;&#x679C;&#x6D3B;&#x671F;&#x8D26;&#x6237;&#x6570;&#x91CF;&#x8FBE;&#x5230;100W+,&#x4E8B;&#x60C5;&#x5C31;&#x4F1A;&#x53D8;&#x5F97;&#x96BE;&#x529E;.&#x8981;&#x8BA1;&#x7B97;&#x5229;&#x606F;,&#x5FC5;&#x987B;&#x5148;&#x628A;&#x8BB0;&#x5F55;&#x4ECE;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x52A0;&#x8F7D;&#x5230;&#x5185;&#x5B58;,&#x518D;&#x8BA1;&#x7B97;.</p>
<p>&#x6240;&#x4EE5;,&#x4E3A;&#x4E86;&#x907F;&#x514D;&#x5927;&#x91CF;&#x6570;&#x636E;&#x7684;&#x64CD;&#x4F5C;,&#x5C31;&#x4F1A;&#x8003;&#x8651;&#x4F7F;&#x7528;&#x6E38;&#x6807;,&#x8FD9;&#x4E2A;&#x4E5F;&#x5C31;&#x662F;&#x4E00;&#x822C;&#x6D3B;&#x671F;&#x8BA1;&#x7B97;&#x5229;&#x606F;&#x4F7F;&#x7528;&#x5B58;&#x50A8;&#x8FC7;&#x7A0B;&#x7684;&#x4E00;&#x4E2A;&#x539F;&#x56E0;.</p>
<p>&#x4E0B;&#x9762;&#x8FD9;&#x79CD;&#x5904;&#x7406;&#x65B9;&#x5F0F;,&#x65E2;&#x80FD;&#x89E3;&#x51B3;&#x6570;&#x636E;&#x91CF;&#x5927;&#x7684;&#x95EE;&#x9898;,&#x53C8;&#x80FD;&#x89E3;&#x51B3;&#x6027;&#x80FD;&#x7684;&#x95EE;&#x9898;</p>
<pre class="language-"><code class="lang-java"><span class="token annotation punctuation">@Autowired</span>
<span class="token keyword">private</span> <span class="token class-name">DataSource</span> dataSource<span class="token punctuation">;</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token class-name">String</span> sql <span class="token operator">=</span> <span class="token string">&quot;SELECT * FROM TB_ORG_USER&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">JdbcTemplate</span> template <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JdbcTemplate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    template<span class="token punctuation">.</span><span class="token function">query</span><span class="token punctuation">(</span>sql<span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">ResultSetExtractor</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token annotation punctuation">@Override</span>
        <span class="token keyword">public</span> <span class="token class-name">Object</span> <span class="token function">extractData</span><span class="token punctuation">(</span><span class="token class-name">ResultSet</span> rs<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">SQLException</span><span class="token punctuation">,</span><span class="token class-name">DataAccessException</span> <span class="token punctuation">{</span>
            <span class="token comment">//&#x8BBE;&#x7F6E;resultSet&#x83B7;&#x53D6;&#x6570;&#x636E;&#x7684;&#x7F13;&#x5B58;</span>
            rs<span class="token punctuation">.</span><span class="token function">setFetchSize</span><span class="token punctuation">(</span><span class="token number">10000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OrgUser</span><span class="token punctuation">&gt;</span></span> userList <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OrgUser</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">while</span><span class="token punctuation">(</span>rs<span class="token punctuation">.</span><span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
                <span class="token class-name">OrgUser</span> user <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">OrgUser</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                user<span class="token punctuation">.</span><span class="token function">setDeptCode</span><span class="token punctuation">(</span>rs<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;DEPT_CODE&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                user<span class="token punctuation">.</span><span class="token function">setId</span><span class="token punctuation">(</span>rs<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;ID&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                user<span class="token punctuation">.</span><span class="token function">setIdCode</span><span class="token punctuation">(</span>rs<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;ID_CODE&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                user<span class="token punctuation">.</span><span class="token function">setPassword</span><span class="token punctuation">(</span>rs<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;PASSWORD&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                user<span class="token punctuation">.</span><span class="token function">setRemark</span><span class="token punctuation">(</span>rs<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;REMARK&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                userList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>user<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span><span class="token punctuation">(</span>userList<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">&gt;</span><span class="token number">10000</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
                    <span class="token comment">//&#x542F;&#x52A8;&#x7EBF;&#x7A0B;,&#x6267;&#x884C;&#x8BA1;&#x7B97;</span>
                    <span class="token comment">// new Thread();</span>
                    userList<span class="token punctuation">.</span><span class="token function">clear</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
            <span class="token comment">//rs.next&#x9000;&#x51FA;,userList&#x4F1A;&#x6709;&#x9057;&#x7559;&#x7684;&#x6570;&#x636E;&#x6CA1;&#x6709;&#x5904;&#x7406;</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span>userList<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">&gt;</span><span class="token number">10000</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
                <span class="token comment">//&#x542F;&#x52A8;&#x7EBF;&#x7A0B;,&#x6267;&#x884C;&#x8BA1;&#x7B97;</span>
                <span class="token comment">// new Thread();</span>
                userList<span class="token punctuation">.</span><span class="token function">clear</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">return</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x89E3;&#x51B3;&#x7684;&#x539F;&#x7406;&#x5F88;&#x7B80;&#x5355;,JDBC&#x4E2D;&#x7684;ResultSet,&#x5728;&#x6570;&#x636E;&#x5E93;&#x5C42;&#x9762;&#x7684;&#x5B9E;&#x73B0;&#x5C31;&#x662F;&#x6E38;&#x6807;,&#x4E3A;&#x4E86;&#x4F7F;&#x7528;&#x6E38;&#x6807;,&#x800C;&#x662F;&#x7528;&#x5B58;&#x50A8;&#x8FC7;&#x7A0B;,&#x662F;&#x4E00;&#x79CD;&#x4E0D;&#x660E;&#x667A;&#x7684;&#x9009;&#x62E9;.&#x66F4;&#x591A;&#x7684;&#x5E94;&#x8BE5;&#x5728;&#x5E94;&#x7528;&#x5C42;&#x9762;&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;,&#x800C;&#x4E0D;&#x662F;&#x5728;&#x6570;&#x636E;&#x5E93;.
&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;,&#x5BF9;&#x6BD4;&#x5B58;&#x50A8;&#x8FC7;&#x7A0B;&#x7684;&#x5904;&#x7406;&#x65B9;&#x5F0F;,&#x552F;&#x4E00;&#x4E0D;&#x597D;&#x7684;,&#x662F;&#x4F1A;&#x6D88;&#x8017;&#x6570;&#x636E;&#x5E93;&#x7684;&#x7F51;&#x7EDC;IO,&#x4F46;&#x662F;&#x53EF;&#x4EE5;&#x51CF;&#x5C11;DB&#x4E0A;&#x7684;CPU&#x538B;&#x529B;,&#x5E26;&#x6765;&#x7684;&#x662F;&#x5E94;&#x7528;&#x7684;&#x5927;&#x6279;&#x91CF;&#x7684;&#x591A;&#x7EBF;&#x7A0B;&#x5904;&#x7406;.</p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; senvon 2020 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">Bilibili,&#x5934;&#x6761;&#x53F7;,&#x5FAE;&#x4FE1;&#x53F7;&#xFF1A;&#x8BF7;&#x641C;&#x7D22;  &#x968F;senvon&#x98DE;
2021-10-15 10:01:05
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="cache-readme.html" class="navigation navigation-prev " aria-label="Previous page: qilucache">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="logTrace-readme.html" class="navigation navigation-next " aria-label="Next page: qilu-logTrace">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"qilu-mybatis","level":"1.3.3","depth":2,"next":{"title":"qilu-logTrace","level":"1.3.4","depth":2,"path":"base/logTrace-readme.md","ref":"base/logTrace-readme.md","articles":[]},"previous":{"title":"qilucache","level":"1.3.2","depth":2,"path":"base/cache-readme.md","ref":"base/cache-readme.md","articles":[]},"dir":"ltr"},"config":{"plugins":["search-plus","-lunr","-search","tbfed-pagefooter","simple-page-toc","insert-logo","back-to-top-button","toggle-chapters","code","lightbox","copy-code-button","search-pro","emphasize","splitter","mermaid-gb3","-sharing","sharing-plus","prism","-highlight","flexible-alerts","page-toc-button","baidu","pageview-count","bilibili","donate","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy senvon 2020","modify_label":"Bilibili,头条号,微信号：请搜索  随senvon飞"},"prism":{},"emphasize":{},"livereload":{},"simple-page-toc":{"maxDepth":5,"skipFirstH1":true},"splitter":{},"search-pro":{},"bilibili":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"code":{"copyButtons":true},"donate":{"alipay":"images/toutiao.jpg","alipayText":"头条号","button":"联系方式","title":"联系方式","wechat":"images/weixin.PNG","wechatText":"公众号"},"fontsettings":{"theme":"white","family":"sans","size":2},"mermaid-gb3":{},"lightbox":{"jquery":true,"sameUuid":false},"page-toc-button":{"maxTocDepth":5,"minTocSize":2},"back-to-top-button":{},"pageview-count":{},"flexible-alerts":{"danger":{"className":"danger","icon":"fa fa-ban","label":"Attention"},"note":{"className":"info","icon":"fa fa-info-circle","label":"Note"},"style":"flat","tip":{"className":"tip","icon":"fa fa-lightbulb-o","label":"Tip"},"warning":{"className":"warning","icon":"fa fa-exclamation-triangle","label":"Warning"}},"copy-code-button":{},"baidu":{"token":"51550945f89f43511a44753249ab6675"},"sharing":{"qq":true,"all":["douban","qq","qzone","weibo"],"douban":false,"facebook":false,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":true,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{},"insert-logo":{"style":"background: none; height: 170px; width: 200px","url":"images/logo3.jpg"},"search-plus":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"启路框架-使用手册","language":"zh-hans","backplugin":["lightbox"],"gitbook":"*","description":"启路框架-使用手册"},"file":{"path":"base/qiluMybatis-readme.md","mtime":"2021-10-15T02:01:05.216Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-10-19T02:57:27.717Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lightbox/js/lightbox.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-flexible-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-page-toc-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-baidu/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

